<template>
  <div>
    <el-container>
         <el-page-header @back="goBack" content="放款">
</el-page-header>
      <el-header>
         <!-- <el-select v-model="value" placeholder="请选择" style="width: 100px">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select> -->
        <el-input
          placeholder="请输入内容"
          prefix-icon="el-icon-search"
          style="width: 300px"
          v-model="sou"
        >
        </el-input>
        <!-- <el-select v-model="value2" placeholder="状态" style="width: 100px">
          <el-option
            v-for="item in options2"
            :key="item.value2"
            :label="item.label"
            :value="item.value2"
          >
          </el-option>
        </el-select> -->
        <el-button type="primary" @click="select()">查询</el-button>
        <el-button type="primary" @click="reset" >重置</el-button>
      </el-header>
      <el-main>
        <el-table :data="tableData" style="width: 100%" height="250">
          <el-table-column type="index"  width="80">
          </el-table-column>
          <input type="hidden" value="bwid" prop="bwid" />
          <el-table-column prop="enterprisename" label="企业名称" width="180">
          </el-table-column>
          <el-table-column prop="code" label="社会信用代码"> </el-table-column>
           <el-table-column prop="amountborrowed" label="注册资本"> </el-table-column>
            <el-table-column prop="salesman" label="业务员" width="80"> </el-table-column>
             <el-table-column prop="status" label="流程状态" width="80">
                  <template slot-scope="scope">
                    <span >{{scope.row.status==3?'未放款':"已提交"}}</span>
                    </template>
                  </el-table-column>
              <el-table-column prop="begindate" label="任务开始时间" width="180"> </el-table-column>
               <el-table-column
      fixed="right"
      label="操作"
      width="100">
      <template slot-scope="scope">
        <el-button @click="contractinfo(scope.row)" type="text" size="small">查看</el-button>
        <el-button type="text" size="small"  @click="open(scope.row)">进件</el-button>
      </template>
    </el-table-column>
        </el-table>
       <el-pagination 
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage4"
      :page-sizes="[1, 3, 5, 7]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="totalRecord">
    </el-pagination>
      </el-main>
    </el-container>
  </div>
</template>
<script>
export default {
  data() {
    return {
       pageSize:2,
      pageUrl:'',
      totalRecord:this.totalRecord,
       currentPage4: 1,
     tableData: [],
      formInline: {
          user: '',
          region: ''
        },
      sou: "",
   
      options: [
        {
          value: "企业名称",
          label: "企业名称",
        },
        {
          value: "社会信用代码",
          label: "社会信用代码",
        },
       
      ],
      options2:[
        {
          value2: "状态",
          label: "状态",
        },
      ],
      
      value: "",
      value2: "",

    };
  },
   created:function(){
              this.getAllborr();
            },
  methods: {
    // 重置
    reset(){
      this.sou= ""
    },
    // 根据条件进行查询
    select(){
     this.getAllborr()
    },
    // 查看合同信息页面
    contractinfo(row){
      console.log("bwidinfo: "+row.bwid);
        this.$router.push({path:"/contractinfo",query:{bwid:row.bwid,step:"放款"}});
    },
    handleSizeChange(val) {
   this.pageSize=val
  console.log("当前条数："+this.currentPage4);
      this.getAllborr();
      
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
   
        this.currentPage4=val;
      this.getAllborr();
    },
     goBack() {
       this.$router.push("/home")
      },
      getAllborr(){
        this.$axios.post("http://localhost:8082/money/allmoney", {
            
            pageIndex:this.currentPage4,
            pageSize:this.pageSize,
            pageUrl:this.sou,
          }).then(resp=>{
        console.log(resp);
        console.log(resp.data);
        this.tableData=resp.data.data.beanList;
        
      this.totalRecord=resp.data.data.totalRecord;
      });
                },
                //  提交
        sub(bwid){
            console.log("bwid:"+bwid)
            this.$axios.post("http://localhost:8082/loan/risksub",{
                bwid:bwid,
                status:4
            }).then(resp=>{
                    console.log(resp.data.data);
                    // 若成功执行一般刷新
                    if(resp.data.data){
                        this.getAllborr();
                         this.$message({
                        type: 'success',
                        message: '成功进件'
                    });          
                    }else{
                        this.$message({
                        type: 'warning',
                        message: '请勿重复进件'
                    })
                    }
            })
         },
    // 打开弹框
       open(row) {
        this.$confirm('此操作将审核通过进入下一阶段, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
            console.log("open:"+row.bwid)
            var bwid = row.bwid;
          this.sub(bwid);
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消进件'
          });          
        });
      }
  },
};
</script>